import {submitFormData, submitJsonData, submitMultipartFormData} from "../../../../../../redare/utils/Request";

/**
 * Created by RdevPlugins.JsPresenterBuilderAction on 2020-03-07 13:02:40.
 */

/**
 * @param body: {mobile, email, name, id, account, key, platform, userPlatform, menuId, needResetPwd, roleIds, status, incMenu, incRole, incRoot, incPwd}
 * @param query: {curPage,pageSize}
 * @returns Promise
 */
export function findUserPage(body, query) {

    return new Promise((resolve, reject) => {

        submitJsonData({
            url: '/api/_webplatform_workbench/user/page',
            bodyParams: body,
            urlParams: query
        }).then(
            result => {
                resolve(result);
            },
            error => reject(error)
        );
    });
}

/**
 * @param body: {mobile, email, name, id, account, key, platform, userPlatform, menuId, needResetPwd, roleIds, status, incMenu, incRole, incRoot, incPwd}
 * @param query: {returnAll,curPage,pageSize}
 * @returns Promise
 */
export function findUserList(body, query) {

    return new Promise((resolve, reject) => {

        submitJsonData({
            url: '/api/_webplatform_workbench/user/list',
            bodyParams: body,
            urlParams: query
        }).then(
            result => {
                resolve(result);
            },
            error => reject(error)
        );
    });
}

/**
 * @param body: {id, account, userPlatform, platform, status, incMenu, incPwd}
 * @param query: {}
 * @returns Promise
 */
export function getUser(body, query) {

    return new Promise((resolve, reject) => {

        submitJsonData({
            url: '/api/_webplatform_workbench/user/detail',
            bodyParams: body,
            urlParams: query
        }).then(
            result => {
                resolve(result);
            },
            error => reject(error)
        );
    });
}

/**
 * @param body: {name, mobile, email, photo, account, pwd, platform, userPlatform, menuId, roleIds, needResetPwd}
 * @param query: {}
 * @returns Promise
 */
export function addUser(body, query) {

    return new Promise((resolve, reject) => {

        submitJsonData({
            url: '/api/_webplatform_workbench/user/add',
            bodyParams: body,
            urlParams: query
        }).then(
            result => {
                resolve(result);
            },
            error => reject(error)
        );
    });
}

/**
 * @param body: {account, name, mobile, email, photo, where: {platform, userPlatform, userId}}
 * @param query: {}
 * @returns Promise
 */
export function modifyUser(body, query) {

    return new Promise((resolve, reject) => {

        submitJsonData({
            url: '/api/_webplatform_workbench/user/modify/info',
            bodyParams: body,
            urlParams: query
        }).then(
            result => {
                resolve(result);
            },
            error => reject(error)
        );
    });
}

/**
 * @param body: {accountId, platform, userPlatform, pwd, needResetPwd}
 * @param query: {}
 * @returns Promise
 */
export function modifyPwd(body, query) {

    return new Promise((resolve, reject) => {

        submitJsonData({
            url: '/api/_webplatform_workbench/user/modify/password',
            bodyParams: body,
            urlParams: query
        }).then(
            result => {
                resolve(result);
            },
            error => reject(error)
        );
    });
}

/**
 * @param body: {accountId, platform, userPlatform, menuId}
 * @param query: {}
 * @returns Promise
 */
export function modifyMenu(body, query) {

    return new Promise((resolve, reject) => {

        submitJsonData({
            url: '/api/_webplatform_workbench/user/modify/menu',
            bodyParams: body,
            urlParams: query
        }).then(
            result => {
                resolve(result);
            },
            error => reject(error)
        );
    });
}

/**
 * @param body: {accountId, roleIds, platform, userPlatform, replace}
 * @param query: {}
 * @returns Promise
 */
export function modifyRole(body, query) {

    return new Promise((resolve, reject) => {

        submitJsonData({
            url: '/api/_webplatform_workbench/user/modify/role',
            bodyParams: body,
            urlParams: query
        }).then(
            result => {
                resolve(result);
            },
            error => reject(error)
        );
    });
}

/**
 * @param body: {accountId, platform, userPlatform, status, statusMsg}
 * @param query: {}
 * @returns Promise
 */
export function modifyStatus(body, query) {

    return new Promise((resolve, reject) => {

        submitJsonData({
            url: '/api/_webplatform_workbench/user/modify/status',
            bodyParams: body,
            urlParams: query
        }).then(
            result => {
                resolve(result);
            },
            error => reject(error)
        );
    });
}

/**
 * @param body: {accountId, platform, userPlatform, roleIds, menuId}
 * @param query: {}
 * @returns Promise
 */
export function modifyPlatform(body, query) {

    return new Promise((resolve, reject) => {

        submitJsonData({
            url: '/api/_webplatform_workbench/user/modify/platform',
            bodyParams: body,
            urlParams: query
        }).then(
            result => {
                resolve(result);
            },
            error => reject(error)
        );
    });
}

/**
 * @param body: {accountId, userPlatform, roleIds}
 * @param query: {}
 * @returns Promise
 */
export function modifyUserPlatform(body, query) {

    return new Promise((resolve, reject) => {

        submitJsonData({
            url: '/api/_webplatform_workbench/user/modify/userplatform',
            bodyParams: body,
            urlParams: query
        }).then(
            result => {
                resolve(result);
            },
            error => reject(error)
        );
    });
}

/**
 * @param body: {accountId, account, platform, userPlatform}
 * @param query: {}
 * @returns Promise
 */
export function delUser(body, query) {

    return new Promise((resolve, reject) => {

        submitJsonData({
            url: '/api/_webplatform_workbench/user/del',
            bodyParams: body,
            urlParams: query
        }).then(
            result => {
                resolve(result);
            },
            error => reject(error)
        );
    });
}

